#ifndef SPEEDPANEL_H
#define SPEEDPANEL_H

#include <QWidget>
#include "BtWidget_global.h"

class BTWIDGET_EXPORT SpeedPanel : public QWidget
{
    Q_OBJECT
public:
    explicit SpeedPanel(QWidget *parent = nullptr);

public:
    void paintEvent(QPaintEvent *event) override;
    QSize sizeHint() const override;

    //相关颜色设置
    void setOutSideColor(QColor color);
    void setBgColor(QColor color);
    void setScalColor(QColor color);
    void setInsideColor(QColor passColor, QColor warnColor, QColor failColor);
    void setHandColor(QColor color);
    void setValuColor(QColor bgColor, QColor textColor);

    void setRange(double max, double min);
    void setTh1Value(double th1);
    void setTh2Value(double th2);
    void setMaxSteps(int count);
    void setMinStepsPerMax(int count);
    void setUnit(const QString strUnit);
    void setValue(double value);
    void setDicimalPrecision(int precision);

signals:

public slots:

private:
    double m_maxValue;     //最大值
    double m_minValue;     //最小值
    double m_value;        //当前值
    double m_threashold1;  //阈值1
    double m_threashold2;  //阈值2
    QString m_strUnit;  //单位

    QColor m_sideColor;
    QColor m_bgColor;
    QColor m_scaleColor;
    QColor m_passColor;
    QColor m_warnColor;
    QColor m_failColor;
    QColor m_HandColor; //指针颜色
    QColor m_valueBgColor;
    QColor m_valueTextColor;

    int m_startAngle;
    int m_spanAngle;

    int m_maxSteps;
    int m_minStepsPerMaxStep;

    int m_precision;

private:
    void drawSideCircle(QPainter* painter); //绘制边框圆
    void drawBgCircle(QPainter* painter);   //绘制背景圆
    void drawScale(QPainter* painter);      //绘制刻度
    void drawInSideArc(QPainter* painter);  //绘制内部弧形
    void drawValueHand(QPainter* painter);  //绘制表盘指针
};

#endif // SPEEDPANEL_H
